<?php

abstract class AppEncoder
{
    abstract function encode();
}

class BlogEncoder extends AppEncoder
{
    public function encode()
    {
        return "Appintment data encode in blog format \n";
    }
}

class MegaEncoder extends AppEncoder
{
    public function encode()
    {
        return "Appintment data encode in Mega format\n";
    }
}

class CommsManager
{
    const Blog = 1,
        Mega = 2;
    private $mode = 1;
    function __construct($mode)
    {
        $this->mode = $mode;
    }

    function getEncoder()
    {
        switch ($this->mode) {
            case (self::Mega):
                return new MegaEncoder();
            default:
                return new BlogEncoder();
        }
    }
}

$comm = new CommsManager(CommsManager::Mega);
$app = $comm->getEncoder();
print $app->encode();